package gui;

import javax.swing.JSlider;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;


public class DoubleProperty implements IProperty<Double>, ChangeListener {
	
	
	private int conversionValue;
	private String 	description;
	private double		min;
	private double		max;
	private double		value;
	private double		step;
	
	public DoubleProperty(String desc, double min, double max,double step, double value){
		this.description = desc;
		this.min = min;
		this.max = max;
		this.value = value;
		this.step = step;
		this.conversionValue = 100;
	}
	
	public DoubleProperty(String desc, double min, double max,double step, double value, int conversionValue){
		this(desc,min,max,step,value);
		this.conversionValue = conversionValue;
	}
	
	public String getDescription() { return description;}
	public Double	getMin(){return this.min;}
	public Double	getMax(){return this.max;}
	public Double	getCurrent(){return this.value;}
	public Double	getStep(){return this.step;}
	public int		getConversionValue(){return this.conversionValue;}
	public void		setConversionValue(int cv){this.conversionValue = cv;}
	public void setMin(Double min){this.min = min;}
	public void setMax(Double max){this.max = max;}
	public void setCurrent(Double value){this.value = value;}
	public void setStep(Double step){this.step = step;}

	@Override
	public void stateChanged(ChangeEvent e) {
		JSlider source = (JSlider)e.getSource();
		this.value = (double)source.getValue()/conversionValue;
		System.out.println("New Value " + value);
	}
}
